00 <include file="Public/head"/>
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css"/>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu="clcwht.fftwgl"/>
    <div class="mianR">
        <h3 class="yonghu">付费提问详情</h3>
        <div class="topic">关联专题
            <if condition="$question.topic_id gt 0">
                <span style="display: inline-block"><i id="topic_name">{$question.topic_name}</i><a href="javascript:;">×</a></span>
                <else />
                <span><i id="topic_name">空调滤芯</i><a href="javascript:;">×</a></span>
                <input id="addTopic" type="button" value="添加专题">
            </if>

        </div>
        <div class="add-topic">
            <h4>添加专题</h4>
            <ul>
                <li><span>专题ID</span><input name="topicId" type="text"><a id="lookup" href="javascript:;">查找</a></li>
                <li><span id="filter_title"></span><span id="filter"></span></li>
                <li><input id="add-btn" type="button" value="添加"><input id="cancel-btn" type="button" value="取消"></li>
            </ul>
        </div>
        <div class="questions-main">
            <div class="questions">
                <dl>
                    <dt>提问</dt>
                    <dd class="clearfix">
                        <div class="questions-cont clearfix">
                            <div class="questions-text">
                                <span>
                                    <notempty name="question.user_avatar">
                                            <img src="{$question.user_avatar}"/>
                                        <else/>
                                            <img src="{:get_style_cdnurl()}paimai/yunying/images/carded_ico.jpg"/>
                                    </notempty>
                                    {$question.user_name}
                                    <i>{$question.create_time}</i>
                                </span>
                                <p>{$question.content}</p>
                                <volist name="question.images" id="qimages">
                                    <p><img src="{$qimages.url}"/></p>
                                </volist>
                            </div>
                            <div class="disable-btn">
                                <if condition="$question.status eq 1">
                                    <span onclick="return update_question_status({$question.question_id},3)">违规禁用</span>
                                    <span onclick="return update_question_status({$question.question_id},4)">用户禁用</span>
                                </if>
                            </div>
                        </div>
                    </dd>
                </dl>
            </div>

            <if condition="$question.is_accept eq 1">
                <div class="questions">
                    <dl>
                        <dt>已采纳牛人回答</dt>
                        <dd class="clearfix">
                            <volist name="question.accept_answer" id="qanswer">
                                <div class="questions-cont clearfix">
                                    <div class="questions-text">
                                        <div>
                                            <span>
                                                <notempty name="qanswer.user_avatar">
                                                        <img src="{$qanswer.user_avatar}"/>
                                                    <else/>
                                                        <img src="{:get_style_cdnurl()}paimai/yunying/images/carded_ico.jpg"/>
                                                </notempty>
                                                {$qanswer.user_name}
                                                <i>{$qanswer.create_time}</i>
                                            </span>
                                            <p>{$qanswer.content}</p>
                                        </div>
                                    </div>
                                    <div class="disable-btn">
                                        <span onclick="return update_answer_status({$qanswer.answer_id},3)">违规禁用</span>
                                        <span onclick="return update_answer_status({$qanswer.answer_id},4)">用户禁用</span>
                                    </div>
                                </div>
                            </volist>
                        </dd>
                    </dl>
                </div>
            </if>


            <notempty name="question.expert_answer">
                <div class="questions">
                    <dl>
                        <dt>启用牛人回答</dt>
                        <dd class="clearfix">
                            <volist name="question.expert_answer" id="qexanswer">
                                <div class="questions-cont clearfix">
                                    <div class="questions-text">
                                        <div>
                                            <span>
                                                 <notempty name="qexanswer.user_avatar">
                                                    <img src="{$qexanswer.user_avatar}"/>
                                                    <else/>
                                                        <img src="{:get_style_cdnurl()}paimai/yunying/images/carded_ico.jpg"/>
                                                </notempty>
                                                {$qexanswer.user_name}
                                                <i>{$qexanswer.create_time}</i>
                                            </span>
                                            <p>{$qexanswer.content}</p>
                                        </div>
                                    </div>
                                    <div class="disable-btn">
                                        <span onclick="return update_answer_status({$qexanswer.answer_id},3)">违规禁用</span>
                                        <span onclick="return update_answer_status({$qexanswer.answer_id},4)">用户禁用</span>
                                    </div>
                                </div>
                            </volist>
                        </dd>
                    </dl>
                </div>
            </notempty>


            <notempty name="question.disable_expert_answer">
                <div class="questions">
                    <dl>
                        <dt>禁用牛人回答</dt>
                        <dd class="clearfix">
                            <volist name="question.disable_expert_answer" id="qdexanswer">
                                <div class="questions-cont clearfix">
                                    <div class="questions-text">
                                        <div>
                                            <span>
                                                 <notempty name="qdexanswer.user_avatar">
                                                    <img src="{$qdexanswer.user_avatar}"/>
                                                    <else/>
                                                        <img src="{:get_style_cdnurl()}paimai/yunying/images/carded_ico.jpg"/>
                                                </notempty>
                                                {$qdexanswer.user_name}
                                                <i>{$qdexanswer.create_time}</i>
                                            </span>
                                            <p>{$qdexanswer.content}</p>
                                        </div>
                                    </div>
                                    <div class="disable-btn">
                                    </div>
                                </div>
                            </volist>
                        </dd>
                    </dl>
                </div>
            </notempty>

            <notempty name="question.normal_answer">
                <div class="questions">
                    <dl>
                        <dt>启用普通回答</dt>
                        <dd class="clearfix">
                            <volist name="question.normal_answer" id="qnormal">
                                <div class="questions-cont clearfix">
                                    <div class="questions-text">
                                        <div>
                                            <span>
                                                <notempty name="qnormal.user_avatar">
                                                    <img src="{$qnormal.user_avatar}"/>
                                                    <else/>
                                                        <img src="{:get_style_cdnurl()}paimai/yunying/images/carded_ico.jpg"/>
                                                </notempty>
                                                {$qnormal.user_name}
                                                <i>{$qnormal.create_time}</i>
                                            </span>
                                            <p>{$qnormal.content}</p>
                                        </div>
                                    </div>
                                    <div class="disable-btn">
                                        <span onclick="return update_answer_status({$qnormal.answer_id},3)">违规禁用</span>
                                        <span onclick="return update_answer_status({$qnormal.answer_id},4)">用户禁用</span>
                                    </div>
                                </div>
                            </volist>
                        </dd>
                    </dl>
                </div>
            </notempty>

            <notempty name="question.disable_normal_answer">
                <div class="questions">
                    <dl>
                        <dt>禁用普通回答</dt>
                        <dd class="clearfix">
                            <volist name="question.disable_normal_answer" id="qdisable">
                                <div class="questions-cont clearfix">
                                    <div class="questions-text">
                                        <div>
                                            <span>
                                                <notempty name="qdisable.user_avatar">
                                                    <img src="{$qdisable.user_avatar}"/>
                                                    <else/>
                                                        <img src="{:get_style_cdnurl()}paimai/yunying/images/carded_ico.jpg"/>
                                                </notempty>
                                                {$qdisable.user_name}
                                                <i>{$qdisable.create_time}</i>
                                            </span>
                                            <p>{$qdisable.content}</p>
                                        </div>
                                    </div>
                                    <div class="disable-btn">
                                        <!--<span onclick="return update_answer_status({$qdisable.answer_id},1)">启用</span>-->
                                    </div>
                                </div>
                            </volist>
                        </dd>
                    </dl>
                </div>
            </notempty>
        </div>

        <div class="yongBtn1">
            <input type="button" class="quxiao" onclick="window.close()" value="关闭"/>
        </div>
    </div>
    <div class="yunBei"></div>
    <div class="clear"></div>
</div>
<script type="text/javascript">
    $(function () {
        $(".questions-cont").each(function () {
            $(".questions-cont:last-child").css("border", "none");
            $(".questions-cont:first-child").css("paddingTop", "0");
        });
    });

    function update_question_status(q_id, status) {
        var post_data = {'id': q_id, 'status': status};
        _myPost('/CommonQuestion/disableQuestion', post_data);
    }

    function update_answer_status(answer_id, status) {
        var post_data = {'a_id': answer_id, 'status': status};
        _myPost('/CommonQuestion/updateAnswerStatus', post_data);
    }

    function _myPost(url, PostData) {
        $(".yunBei").css("display", "block").unbind('click')
        $(".loading").fadeIn();
        $.post(url, PostData, function (data) {
            if (data.code != 200) {
                $(".loading").fadeOut();
                $(".yunBei").css("display", "none");
                shibai_alert(data.msg);
                return false;
            }
            btn_alert("操作成功", 1000, function () {
                window.location.reload();
            });
        }, 'json');
    }


    $(function () {
        $("#addTopic").on("click", function () {
            $(".add-topic").fadeIn();
            $(".add-topic").css("marginTop", -($(".add-topic").height()) / 2 + "px");
            $(".yunBei").css("display", "block");
        })
        $("#cancel-btn").click(function () {
            $(".yunBei").css("display", "none");
            $(".add-topic").fadeOut();
        })
        $("#add-btn").click(function () {
            var filter = $('#filter').text();
            if(filter == ''){
                shibai_alert('抱歉，请先查找专题');
                return false;
            }
            var topicId = $("input[name='topicId']").val();
            $.ajax({
                type: 'post',
                url: '/CommonQuestion/addTopic',
                data: {qid:"{$question.question_id}",tid: topicId},
                async: false,
                dataType: 'JSON',
                success: function (data) {
                    if (data.code != 200) {
                        shibai_alert(data.msg);
                        return false;
                    }
                    btn_alert(data.msg);
                    $(".yunBei").css("display", "none");
                    $(".add-topic").fadeOut();
                    $(".topic span").css("display", "inline-block");
                    $(".topic span i").html($("#filter").html());
                    $("#addTopic").hide();
                }
            });
        })
        $(".topic span a").on("click", function () {
            confirm_alert("<p class='cancel-title'>删除关联专题</p><p class='cancel-topic'>确认删除关联专题？</p>")
        });
        $("body").on("click", "input.determine", function () {
            var topicId = $("input[name='topicId']").val();
            var oldTopicId = "{$question.topic_id}";
            $.ajax({
                type: 'post',
                url: '/CommonQuestion/delTopic',
                data: {qid:"{$question.question_id}"},
                async: false,
                dataType: 'JSON',
                success: function (data) {
                    if (data.code != 200) {
                        shibai_alert(data.msg);
                        return false;
                    }
                    btn_alert(data.msg);
                    if (oldTopicId > 0) {
                        window.location.reload();
                    } else {
                        $(".chenggong1").remove();
                        $(".topic span").css("display", "none");
                        $(".topic span i").html("");
                        $("#addTopic").show();
                        $(".yunBei").css("display", "none");
                    }
                }
            });
        });

        $('#lookup').on('click', function () {
            var topicId = $("input[name='topicId']").val();
            if (topicId == '') {
                shibai_alert('抱歉，专题ID不能为空');
                return false;
            }
            $.ajax({
                type: 'post',
                url: '/Topic/checkTopic',
                data: 't_id=' + topicId,
                async: false,
                dataType: 'JSON',
                success: function (data) {
                    if (data.code != 200) {
                        $("#filter").text('');
                        $("#filter_title").text('');
                        shibai_alert(data.msg);
                        return false;
                    }
                    $("#filter_title").text('专题名称');
                    $("#filter").text(data.data.topic_name);
                }
            });
        });
    });
</script>
<include file="Public/foot"/>